﻿using System;
using System.ComponentModel;
using System.Reflection;

namespace uTube.Core.DataTypes.PrevalueEditors
{
	/// <summary>
	/// Abstract class for the Prevalue options.
	/// </summary>
	public abstract class AbstractOptions
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="AbstractOptions"/> class.
		/// </summary>
		public AbstractOptions()
		{
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="AbstractOptions"/> class.
		/// </summary>
		/// <param name="loadDefaults">if set to <c>true</c> [load defaults].</param>
		public AbstractOptions(bool loadDefaults)
		{
			if (loadDefaults)
			{
				var type = this.GetType();

				foreach (var property in type.GetProperties())
				{
					foreach (DefaultValueAttribute attribute in property.GetCustomAttributes(typeof(DefaultValueAttribute), true))
					{
						property.SetValue(this, attribute.Value, null);
					}
				}
			}
		}

		/// <summary>
		/// Gets or sets the name of the application.
		/// </summary>
		/// <value>The name of the application.</value>
		[DefaultValue("uTube")]
		public string ApplicationName { get; set; }

		/// <summary>
		/// Gets or sets the developer key.
		/// </summary>
		/// <value>The developer key.</value>
		[DefaultValue("AI39si5qYIjvoCEnHLturSZhoFzb7J6OHU1yvdGBTRaHOmPLbrm5EF5-dBO7e6zPhsMMhQVgqug_rG3UWMkvodOdPEdtqdpiEQ")]
		public string DeveloperKey { get; set; }
	}
}
